<?php /* УТФ-8:fix */

class SPItpl__smarty extends Smarty
{
    public function __construct( $tplcfg )
    {
        if( is_array( $tplcfg ) === false )
        {
            return;
        }

        $this->compile_check = $tplcfg['compile_check'];
        $this->debugging     = false;

        $this->template_dir  = $tplcfg['template_dir'];
        $this->cache_dir     = $tplcfg['cache_dir'];
        $this->compile_dir   = $tplcfg['compile_dir'];
        $this->config_dir    = $tplcfg['config_dir'];

        if( is_array( $tplcfg['config_load'] ) === true )
        foreach( $tplcfg['config_load'] as $config_load )
        {
            list( $config_load, $config_section ) = explode( ':', $config_load );
            $this->config_load( $config_load, $config_section );
        }

        if( is_array( $tplcfg['load_filter'] ) === true )
        foreach( $tplcfg['load_filter'] as $load_filter )
        {
            list( $filter_type, $filter_function ) = explode( ':', $load_filter );
            $this->load_filter( $filter_type, $filter_function );
        }

        if( class_exists('SPItpl__smarty__extensions') === true )
        {
            $extensions = new SPItpl__smarty__extensions;

            $this->register_modifier( 'spiTruncate',     array( $extensions, 'spiTruncate' ) );
            $this->register_modifier( 'spiMediaPreview', array( $extensions, 'spiMediaPreview' ) );
            $this->register_modifier( 'spiStripTags',    array( $extensions, 'spiStripTags' ) );
            $this->register_modifier( 'spiIsEmptyHtml',  array( $extensions, 'spiIsEmptyHtml' ) );
            $this->register_modifier( 'spiBbcode',       array( $extensions, 'spiBbcode' ) );
        }
    }

    public function clear()
    {
        return $this->clear_all_assign();
    }

    public function compile( $template_filename )
    {
        return $this->fetch( $template_filename );
    }

    public function echo_compile( $template_filename )
    {
        return $this->display( $template_filename );
    }
}
